<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2019/4/27
 * Time: 15:04
 */

namespace common\sources\write\buscashlog;

use Yii;

class BusCashLogAccess implements IBusCashLogAccess
{
    public function addBusCashLog($data)
    {
        return Yii::$app->db->createCommand()->insert('bus_cash_log', [
            'bus_id' => $data['bus_id'],
            'serial_num' => $data['serial_num'],
            'money' => $data['money'],
            'arrival_money' => $data['arrival_money'],
            'account_num' => $data['account_num'],
            'username' => $data['username'],
            'status' => $data['status'],
            'remark' => $data['remark'],
            'operator' => $data['operator'],
            'create_time' => time(),
        ])->execute();
    }

    public function AuditCash($data)
    {
        $cash = BusinessCash::findOne(['id' => $data['id']]);
        if ($cash) {
            $cash->cash_status = $data['status'];
            if ($cash->save()) {
                return true;
            }
        }
        return false;
    }
}